<script id="setup-code">

var M = function(x, y, rad, vn, ang){
    this.x = x;
    this.y = y;
    this.radius = rad;
    this.v = vn;
    this.ang = ang || 0;
    this.incAng = 2*Math.PI/this.v;
    
    this.points = [];
    
    this.calculate = function(){
      this.points = [];
      var r = this.ang;
      for(var i = 0; i < this.v; i++){
         this.points.push([
           this.radius*Math.cos(r) + this.x,
           this.radius*Math.sin(r) + this.y
         ]);
         r+=this.incAng;
      }
    };
    
    this.render = function(runtime){
      this.calculate();
      runtime.complex(this.points, true);
    };
};

this.triangle = new M(100,100, 30, 3);


this.runtime.on('keydown', function(){
  if(this.keyCode == 38){
     this.triangle.ang+=0.1;
  }else if(this.keyCode == 40){
     this.triangle.ang-=0.1;
  }
   
});

</script>
<script id="exec-code">
this.triangle.render(this);
</script>
